<%-- 
    Document   : pesquisarReserva
    Created on : 06/12/2011, 09:59:53
    Author     : 0450103
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="DAO.EspacoDAO"%>
<%@page import="Model.Espaco"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Exceptions.PrivilegioInsuficienteException"%>
<%@page import="Model.Usuario"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file = "autenticacaoAdministrador.jsp"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Sistema Controle de Reservas</title>
    </head>
    <body>        
        <%
            ArrayList<Espaco> espacos = (ArrayList) request.getAttribute("espacos");
            if(espacos == null){
                throw new ServletException();
            }
        %>
        <h1>Espaços encontrados:</h1>
        <table border="1">
                <tr>
                    <th>Id do Espaço</th>
                    <th>Número do Espaço</th>
                    <th>Endereço</th>
                    <th>Capacidade</th>
                    <th>Descrição</th>
                    <th>Tipo de Espaço</th>
                    <th>Ação</th>
                </tr>
                <c:forEach var="espaco" items="${espacos}">
                    <tr>
                        <td>${espaco.id_espaco}</td>
                        <td>${espaco.num_espaco}</td>
                        <td>${espaco.end.cidade}, ${espaco.end.rua} ${espaco.end.numero}</td>
                        <td>${espaco.capacidade}</td>
                        <td>${espaco.descricao}</td>
                        <td>${espaco.tipo.nome}</td>
                        <td>
                            <form name="form" method="post" action="MainAccessServlet" accept-charset="iso-8859-1,utf-8">
                                <input type="hidden" name="id" value="${espaco.id_espaco}"/>
                                <input type="hidden" name="link" value="${link}"/>
                                <input type="hidden" name="cmd" value="pesquisarEspaco"/>
                                <%
                                    String link = (String) request.getAttribute("link");
                                    if(!link.equals("removerEspaco.jsp")){ 
                                %>
                                    <input type="submit" value="Alterar"/>
                                <% } else { %>                                    
                                    <input type="submit" value="Remover"/>
                                <% } %>
                            </form>
                        </td>
                    </tr>
                </c:forEach>
        </table>
    </body>
</html>
